﻿using System;

namespace TextEditor
{
   

    public class A_SetSup : A_Action
    {
        public override string ActionName()
        {
            return "sup";
        }

        public override int CheckState()
        {
            ZYTextChar currentElement = base.myOwnerDocument.Content.GetPreChar();    
            if (currentElement != null)
            {
                return (currentElement.Sup ? 1 : 0);
            }
            return -1;
        }

        public override A_Action Clone()
        {
            A_SetSup sup = new A_SetSup();
            sup.BaseCloneFrom(this);
            return sup;
        }

        public override bool Execute()
        {
            base.myOwnerDocument.SetSelectionSup(base.Param1 == "1");
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }

        public override bool UIExecute()
        {
            base.myOwnerDocument.SetSelectionSup(this.CheckState() == 0);
            return true;
        }
    }
}

